package com.landeb.shop.huo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.landeb.shop.R;

import java.util.List;

/**
 * Created by blade on 2016/11/16.
 */

public class ActSearchSimpleAdapter extends BaseAdapter {

    private List<String> mList;
    private Context mContext;
    private LayoutInflater mInflater;

    public ActSearchSimpleAdapter(Context context, List<String> list) {
        mContext = context;
        mList = list;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder holder = null;
        if (view == null) {
            view = mInflater.inflate(R.layout.item_act_search_grid_view, viewGroup, false);

            holder = new ViewHolder();

            holder.mTitle = (TextView) view.findViewById(R.id.tv_item_act_search_gridView);

            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        String title = mList.get(i);
        holder.mTitle.setText(title);

        return view;

    }

    private class ViewHolder {
        private TextView mTitle; //文字
    }
}
